package com.zhiche.lisa.mdm.service.impl;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zhiche.lisa.mdm.dao.mapper.LocationTypeMapper;
import com.zhiche.lisa.mdm.dao.model.LocationType;
import com.zhiche.lisa.mdm.service.ILocationTypeService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * <p>
 * 地址类型 服务实现类
 * </p>
 *
 * @author qichao
 * @since 2018-06-18
 */
@Service
public class LocationTypeServiceImpl extends ServiceImpl<LocationTypeMapper, LocationType> implements ILocationTypeService {

    @Override
    public LocationType getLocationTypeByValue(String value) {
        LocationType locationType = new LocationType();
        EntityWrapper<LocationType> ew = new EntityWrapper<>();
        ew.eq("value",value);
        List<LocationType> locationTypes = this.selectList(ew);
        if(!CollectionUtils.isEmpty(locationTypes)){
            locationType = locationTypes.get(0);
        }
        return  locationType;
    }
}
